package com.yx.cloud.utils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;

import com.yx.cloud.R;

/**
 * 界面跳转动画
 */
public class Intent_utils {

    public static void enterIntent2(Context context, Class class1) {
        Intent intent = new Intent(context, class1);
        context.startActivity(intent);
        ((Activity) context).overridePendingTransition(R.anim.out_to_left,R.anim.in_from_right);
    }

    public static void enterIntent(Context context, Class class1) {
        Intent intent = new Intent(context, class1);
        context.startActivity(intent);
        ((Activity) context).overridePendingTransition(R.anim.in_from_right,
                R.anim.out_to_left);
    }

    public static void enterIntentContext(Context context, Class class1, String src1, String src2) {
        Intent intent = new Intent(context, class1);
        intent.putExtra(src1, src2);
        context.startActivity(intent);
        ((Activity) context).overridePendingTransition(R.anim.in_from_right,
                R.anim.out_to_left);
    }
    public static void enterIntentContextString(Context context, Class class1, String src1, String src2, String src3, String src4) {
        Intent intent = new Intent(context, class1);
        intent.putExtra(src1, src2);
        intent.putExtra(src3, src4);
        context.startActivity(intent);
        ((Activity) context).overridePendingTransition(R.anim.in_from_right,
                R.anim.out_to_left);
    }
    public static void enterIntentContextString_3(Context context, Class class1, String src1, String src2, String src3, String src4, String src5, String src6) {
        Intent intent = new Intent(context, class1);
        intent.putExtra(src1, src2);
        intent.putExtra(src3, src4);
        intent.putExtra(src5, src6);
        context.startActivity(intent);
        ((Activity) context).overridePendingTransition(R.anim.in_from_right,
                R.anim.out_to_left);
    }

    public static void enterIntentContextInt(Context context, Class class1, String src1, int src2) {
        Intent intent = new Intent(context, class1);
        intent.putExtra(src1, src2);
        context.startActivity(intent);
        ((Activity) context).overridePendingTransition(R.anim.in_from_right,
                R.anim.out_to_left);
    }

    public static void enterIntentMenu(Context context, Class class1) {
        Intent intent = new Intent(context, class1);
        context.startActivity(intent);
        ((Activity) context).overridePendingTransition(0,
                0);
    }

    public static void enterIntentResult(Activity activity, Class class1, String str) {
        Intent intent = new Intent(activity, class1);
        intent.putExtra("tag", str);
        activity.startActivityForResult(intent, 1111);
        ((Activity) activity).overridePendingTransition(0,
                0);
    }

    public static void backIntent(Context context) {
        ((Activity) context).finish();
        ((Activity) context).overridePendingTransition(R.anim.in_from_left, R.anim.out_to_right);
    }

    public static void backIntent(Context context, Class class1) {
        ((Activity) context).finish();
        Intent intent = new Intent(context, class1);
        context.startActivity(intent);
        ((Activity) context).overridePendingTransition(R.anim.in_from_left, R.anim.out_to_right);
    }

    public static void enterIntentFromBottom(Context context, Class class1) {
        Intent intent = new Intent(context, class1);
        context.startActivity(intent);
        ((Activity) context).overridePendingTransition(R.anim.enteralpha,
                R.anim.default_anim);
    }

    public static void enterIntentFromBottomQuickly(Context context, Class class1) {
        Intent intent = new Intent(context, class1);
        context.startActivity(intent);
        ((Activity) context).overridePendingTransition(R.anim.enteralpha_quickly,
                R.anim.default_anim_quickly);
    }

    public static void backIntentFromTop(Context context) {
        ((Activity) context).finish();
        ((Activity) context).overridePendingTransition(R.anim.default_anim, R.anim.exitalpha);
    }

    public static void backIntentFromTopQuickly(Context context) {
        ((Activity) context).finish();
        ((Activity) context).overridePendingTransition(R.anim.default_anim_quickly, R.anim.exitalpha_quickly);
    }

    /**
     * 跳转至商铺
     *
     * @param activity Activity
     * @param url      商铺地址
     */
    public static void gotoShop(Activity activity, String url) {
        try {
            Intent intent = new Intent();
            intent.setAction("android.intent.action.VIEW");
            intent.setData(Uri.parse(url));
            activity.startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
